package com.example.testcamara;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;

import org.json.JSONException;
import org.json.JSONObject;

public class MyApp extends Application {

    private String JSON = "{\"ccrcCode\":\"ccrc_pre_gaode_drive_audio_erhuan\",\"clientInfo\":\"{\\\"appInfo\\\":{\\\"appKey\\\":\\\"com.qx.yue.special\\\",\\\"appName\\\":\\\"测网司机端\\\",\\\"appVersion\\\":\\\"5.90.0.0097\\\",\\\"sdkType\\\":\\\"cloud\\\",\\\"sdkVersion\\\":\\\"1.0.11\\\",\\\"wkVersion\\\":\\\"1.1.6\\\"},\\\"deviceInfo\\\":{\\\"brand\\\":\\\"HUAWEI\\\",\\\"dID\\\":\\\"ffffffff-ec2b-b70a-0000-0000292f049e\\\",\\\"model\\\":\\\"NOH-AN00\\\",\\\"netWorkType\\\":\\\"WIFI\\\",\\\"osName\\\":\\\"Android\\\",\\\"osVersion\\\":\\\"12\\\"},\\\"ts\\\":1691649689706}\",\"context\":\"{\\\"appKey\\\":\\\"com.qx.yue.special\\\",\\\"appName\\\":\\\"测网司机端\\\",\\\"ccrcCode\\\":\\\"ccrc_pre_gaode_drive_audio_erhuan\\\",\\\"ccrcResults\\\":{\\\"dataId\\\":\\\"2308090448201000337_47867a02-4514-4831-af60-e6d0fc610126\\\",\\\"extras\\\":{\\\"adcode\\\":\\\"110105\\\",\\\"orderId\\\":\\\"2308090448201000337\\\",\\\"sampleID\\\":\\\"2308090448201000337_47867a02-4514-4831-af60-e6d0fc610126\\\",\\\"segmentIndex\\\":138,\\\"ts\\\":1691649689294},\\\"localCroAsr\\\":{\\\"absoluteStartTime\\\":1691649689304,\\\"asr_res\\\":{\\\"endTime\\\":14.970000267028809,\\\"result\\\":\\\"你说这那边是吧就后开出这考老式用可的他就手职验点走了其台现在有天额车就是来应天是可以点就说他白个也时候还怎去啊你看这个情到有\\\",\\\"startTime\\\":0.0},\\\"success\\\":true,\\\"version\\\":\\\"cro_ctc_att_device_0.1\\\"}},\\\"dataId\\\":\\\"2308090448201000337_47867a02-4514-4831-af60-e6d0fc610126\\\",\\\"deviceModel\\\":\\\"NOH-AN00\\\",\\\"osName\\\":\\\"Android\\\",\\\"osVersion\\\":\\\"12\\\",\\\"pid\\\":\\\"2308090448201000337\\\",\\\"prepareID\\\":\\\"PREPARE_CCRC_PRE_GAODE_DRIVE_AUDIO_ERHUAN_D2943A85-3475-4E4C-A1E8-FFEEE4C5C98E\\\",\\\"sceneName\\\":\\\"localCroAsr\\\",\\\"sdkVersion\\\":\\\"1.0.11\\\",\\\"wukong_uuid\\\":\\\"f661fe85-bde7-4bdb-9ba9-0d74846e12b8\\\"}\",\"extras\":\"\",\"pId\":\"2308090448201000337\",\"riskInfos\":\"[{\\\"dataId\\\":\\\"2308090448201000337_47867a02-4514-4831-af60-e6d0fc610126\\\",\\\"risk\\\":\\\"骚扰\\\",\\\"riskLevel\\\":\\\"white\\\",\\\"ruleId\\\":\\\"R_18410803\\\"}]\",\"ts\":1691649689709}";

    static String json2 = "xml content = [<div x=\"75126\" _line=\"285428007\" class=\"order_pool_card_wrap_list\" ><div x=\"75128\" _line=\"742997001\" class=\"opc_wrapper\" ><div x=\"75129\" _line=\"742997002\" class=\"opc_wrapper_parent\" ><div x=\"75130\" _line=\"742997025\" class=\"opc_header\" ><div x=\"75131\" _line=\"742997026\" style=\"background-image:url(path://ajx_bundle_common_business/imgs/a58d6c7219z.webp);border-radius:12px 0 32px 0;\" ><label x=\"75132\" _line=\"742997027\" text=\"实时\" class=\"opc_header-text\" ></label></div><div x=\"75133\" _line=\"742997015\" class=\"opc_to_map\" onclick=\"ajx.ui.root.AJXhandler_fox.click\" ><label x=\"75134\" _line=\"742997016\" class=\"opc_to_map-text\" text=\"查看地图\" ></label><img x=\"75135\" _line=\"742997017\" class=\"opc_to_map-icon\" src=\"path://ajx_bundle_common_business/imgs/655ea568b1z.webp\" ></img></div></div><div x=\"75136\" _line=\"742997028\" class=\"opc_distance_info\" ><div x=\"75137\" _line=\"742997029\" class=\"opc_distance_info_box\" ><div x=\"75138\" _line=\"742997030\" class=\"opc_distance_info_msg\" ><label x=\"75139\" _line=\"742997031\" class=\"opc_distance_info_msg-num\" text=\"3.6\" ></label><label x=\"75140\" _line=\"742997032\" class=\"opc_distance_info_msg-unit\" text=\"公里\" ></label></div><label x=\"75141\" _line=\"742997033\" class=\"pc_distance_info-text\" text=\"全程\" ></label></div><div x=\"75142\" _line=\"742997029\" class=\"opc_distance_info_box\" ><div x=\"75143\" _line=\"742997030\" class=\"opc_distance_info_msg\" ><label x=\"75144\" _line=\"742997031\" class=\"opc_distance_info_msg-num\" text=\"1.7\" ></label><label x=\"75145\" _line=\"742997032\" class=\"opc_distance_info_msg-unit\" text=\"公里\" ></label></div><label x=\"75146\" _line=\"742997033\" class=\"pc_distance_info-text\" text=\"接驾距离\" ></label></div><div x=\"75147\" _line=\"742997029\" class=\"opc_distance_info_box\" ><div x=\"75148\" _line=\"742997030\" class=\"opc_distance_info_msg\" ><label x=\"75149\" _line=\"742997031\" class=\"opc_distance_info_msg-num\" style=\"color:#F66A14;font-weight:bold;\" text=\"8.77\" ></label><label x=\"75150\" _line=\"742997032\" class=\"opc_distance_info_msg-unit\" style=\"color:#F66A14;fo";

    private static Application mIns;
    private static Context sApplicationContext;

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        mIns = this;
        sApplicationContext = base;
//        super.attachBaseContext(LanguageUtil2.attachBaseContext(base));
    }

    @Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // 系统资源配置发生更改，例如主题模式，需要重新刷新多语言
//        LanguageUtil.attachBaseContext(this);
    }

    @Override
    public void onCreate() {
        super.onCreate();

        String jsss = "{\n" +
                "    \"code\": 0,\n" +
                "    \"data\": null\n" +
                "}";
        try {
            JSONObject jsonObject = new JSONObject(jsss);
            Log.e("EEED", jsonObject.optString("data"));
            Toast.makeText(this, jsonObject.optString("data"), Toast.LENGTH_SHORT).show();
        } catch (JSONException e) {
            e.printStackTrace();
        }

//        String sss = Test2.processUriPath("/sdcard/xxx.mp4");
//        Log.e("EEDD", sss);

//        try {
//            String aaa = "{\"action\":\"wechatMiniProgram\",\"userName\":\"gh_283069f74286\",\"path\":\"index/index?orderId=23122113280001006143\",\"miniprogramType\":0}";
//            JSONObject jsonObject = new JSONObject(aaa);
//            Log.e("EEDD", "" + jsonObject);
//        } catch (JSONException e) {
//            throw new RuntimeException(e);
//        }
//
//        try {
//            JSONObject jsonObject = new JSONObject(json2);
//            String message = jsonObject.optString("message");
//            String stack = jsonObject.optString("stack");
//        } catch (Exception e) {
//            Log.e("SSDD", e.getMessage());
//        }
//
//        try {
//            JSONObject jsonObject = new JSONObject(JSON);
//            JSONObject context = new JSONObject(jsonObject.optString("context"));
//            JSONObject ccrcResults = context.optJSONObject("ccrcResults");
//            String dataId = ccrcResults.optString("dataId");
//            JSONObject extras = ccrcResults.getJSONObject("extras");
//            long ts = extras.optLong("ts");
//
//            JSONObject localCroAsr = ccrcResults.getJSONObject("localCroAsr");
//            JSONObject asr_res = localCroAsr.getJSONObject("asr_res");
//            String result = asr_res.optString("result");
////            SecurityServiceWrap.putASRResult(dataId,result,ts);
//        } catch (Exception ignored) {
//            Log.e("EEDD", "exception: " + ignored.getMessage());
//        }
    }

    public static Application getIns() {
        return mIns;
    }
}
